﻿using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Transactions;
using System.Web.Mvc;
using yiCommerce.Core;
using yiCommerce.Core.Data;
using yiCommerce.Core.Domain;
using yiCommerce.Core.Domain.Addresses;
using yiCommerce.Core.Domain.Brands;
using yiCommerce.Core.Domain.Categorys;
using yiCommerce.Core.Domain.Customers;
using yiCommerce.Core.Domain.FriendShips;
using yiCommerce.Core.Domain.Messges;
using yiCommerce.Core.Domain.Orders;
using yiCommerce.Core.Domain.Payments;
using yiCommerce.Core.Domain.Pictures;
using yiCommerce.Core.Domain.Products;
using yiCommerce.Core.Domain.Securitys;
using yiCommerce.Core.Domain.Shippings;
using yiCommerce.Core.Domain.ShoppingCarts;
using yiCommerce.Core.Domain.Shops;
using yiCommerce.Core.Domain.Statuses;
using yiCommerce.Core.Domain.Tags;
using yiCommerce.Core.Domain.Tradings;
using yiCommerce.Data;
using yiCommerce.Service.Securitys;

namespace yiCommerce.Areas.Install.Controllers
{
    public class InstallController: Controller
    {
        private IRepository<Tag> _tagsRep;
        private IRepository<StatusPointDetail> _statusPointDetailRep;
        private IRepository<CustomerLogo> _customerLogoRep;
        private IRepository<CustomerRole> _customerRoleRepository;
        private IRepository<Customer> _customerRepository;
        private IRepository<Shop> _shopRepository;
        private IRepository<ProductAttribute> _productAttributeRepository;
        private IRepository<SpecificationAttribute> _speficationAttributreRepostiory; 
        private IRepository<SpecificationAttributeOption> _speficationAttributreOptionRepostiory;
        private IRepository<Order> _orderRep;
        private IRepository<Trading> _tradingRep;
        private IRepository<TradingId> _tradingIdRep;
        private IRepository<SystemSetting> _systemSettingRep;
        private IRepository<AlipayPaymethodSetting> _alipaysettingrep;
        private IRepository<Brand> _brandRep;
        private IRepository<Category> _catRep;
        private IRepository<Address> _addressRep;
        private IRepository<ShoppingCartItem> _shoppingCartItemRep;
        private IRepository<Product> _productRepository;
        private IRepository<ProductVariant> _productVariantRepository;
        private IRepository<Picture> _picturerep;
        private IRepository<ProductPicture> _productpicturerep;
        private IRepository<PermissionRecord> _permissionRecordRep;
        private IRepository<Shipment> _shipmentRecordRep;
        private IRepository<StatusPicture> _statusPicRep;
        private IRepository<Status> _statusRep;
        private IRepository<FriendShip> _friendShipRep;
        private IEncryptionService _encryptionService;
        private IMongoRepository<Message> _messageRep;

        public InstallController(

            IRepository<FriendShip> friendShipRep,
            IRepository<Status> statusRep,
            IRepository<StatusPicture> statusPicRep,
            IRepository<Shipment> shipmentRep,
            IRepository<PermissionRecord> permissionRecordRep,
            IEncryptionService encryptionService,
            IRepository<CustomerRole> customerRoleRepository, IRepository<Customer> customerRepository, IRepository<Shop> shopRepository, IRepository<ProductAttribute> productAttributeRepository, IRepository<SpecificationAttribute> speficationAttributreRepostiory, IRepository<SpecificationAttributeOption> speficationAttributreOptionRepostiory, IRepository<Order> orderRep, IRepository<Trading> tradingRep, IRepository<TradingId> tradingIdRep, IRepository<SystemSetting> systemSettingRep, IRepository<AlipayPaymethodSetting> alipaysettingrep, IRepository<Brand> brandRep, IRepository<Category> catRep, IRepository<Address> addressRep, IRepository<ShoppingCartItem> shoppingCartItemRep, IRepository<Product> productRepository, IRepository<ProductVariant> productVariantRepository, IRepository<Picture> picturerep, IRepository<ProductPicture> productpicturerep, IMongoRepository<Message> messageService, IRepository<CustomerLogo> customerLogoRep, IRepository<StatusPointDetail> statusPointDetailRep, IRepository<Tag> tagsRep)
        {
            _friendShipRep = friendShipRep;
            _statusRep = statusRep;
            _statusPicRep = statusPicRep;
            _shipmentRecordRep = shipmentRep;
            _permissionRecordRep = permissionRecordRep;
            _encryptionService = encryptionService;
            _customerRoleRepository = customerRoleRepository;
            _customerRepository = customerRepository;
            _shopRepository = shopRepository;
            _productAttributeRepository = productAttributeRepository;
            _speficationAttributreRepostiory = speficationAttributreRepostiory;
            _speficationAttributreOptionRepostiory = speficationAttributreOptionRepostiory;
            _orderRep = orderRep;
            _tradingRep = tradingRep;
            _tradingIdRep = tradingIdRep;
            _systemSettingRep = systemSettingRep;
            _alipaysettingrep = alipaysettingrep;
            _brandRep = brandRep;
            _catRep = catRep;
            _addressRep = addressRep;
            _shoppingCartItemRep = shoppingCartItemRep;
            _productRepository = productRepository;
            _productVariantRepository = productVariantRepository;
            _picturerep = picturerep;
            _productpicturerep = productpicturerep;
            _messageRep = messageService;
            _customerLogoRep = customerLogoRep;
            _statusPointDetailRep = statusPointDetailRep;
            _tagsRep = tagsRep;
        }

        public ActionResult Index()
        {
            using (var trans = new TransactionScope())
            {


              

                DeleteOrders();
                DeleteTradings();
                DeleteTradingId();
                DeleteSystemSetting();
                DeleteShoppingCartItem();


                DeleteProductSpecificationAttributeMapping();
                DeleteSpecificationAttributeOption();
                DeleteSpecificationAttribute();

                DeleteShipment();

                DeleteProductVariantAttributeValue();
                DeleteProductVariantProductAttributeMapping();
                DeleteProductAttribute();

                DeleteOrderProductVariant();
                DeleteProductVariant();

                DeleteProductPicutreMapping();
                DeleteProductCategoryMapping();
                DeleteProductBrandMapping();
                DeleteStatusPointDetail();
                DeleteStatuses();

                DeleteStatusPictures();

                DeleteProduct();
              
                DeleteOrder();

                DeletePermissionRecordRoleMapping();
                DeletePermissionRecord();

                DeleteCustomerRoleMapping();
                DeleteCustomerAddress();
                DeleteCustomerRole();
                DeleteCustomer();
                DeleteAddress();
                DeleteBrand();
                DeleteCategory();
                DeleteAlipayPaymethodSetting();
                DeleteCustomerLogs();

                DeletePictures();
             
                DeleteFriendShip();
                DeleteMessages();

                DeleteTags();
                InstallSystemSetting();
                InstallAlipayPaymethodSetting();
                InstallBrand();
                InstallCategory();

                InstallCustomerRole();
                InstallPermissionRecordRoleMapping();
                InstallMessages();

                var admintratorId = InstallAdministrator();
                var shopOwenerId = InstallShopOwner();
                var customerId = InstallCustomer();

                InstallProductAttribute();
                InstallShop(shopOwenerId, admintratorId, customerId);

                //var customerId = InstallCustomer();
                InstallSpecificationAttributes();
                InstallTags(admintratorId);

                trans.Complete();
            }
            //return View();
            //return View("PluginSysWebRegForm.Views.RegForm.Index");
            return View("~/Areas/Install/Views/Install/Index.cshtml");


        }

        private void InstallTags(int admintratorId)
        {
            var newTag = new Tag()
                {
                    CreateAt = DateTime.Now,
                    CreatorId = admintratorId,
                    Deleted = false,
                    TagName = "动漫",
                    TagValue = "动漫",
                    CountTaged = 0,
                };
            _tagsRep.Insert(newTag);


            newTag = new Tag()
            {
                CreateAt = DateTime.Now,
                CreatorId = admintratorId,
                Deleted = false,
                TagName = "音乐",
                TagValue = "音乐",
                CountTaged = 0,
            };
            _tagsRep.Insert(newTag);

            newTag = new Tag()
            {
                CreateAt = DateTime.Now,
                CreatorId = admintratorId,
                Deleted = false,
                TagName = "健身",
                TagValue = "健身",
                CountTaged = 0,
            };
            _tagsRep.Insert(newTag);

            newTag = new Tag()
            {
                CreateAt = DateTime.Now,
                CreatorId = admintratorId,
                Deleted = false,
                TagName = "烘焙",
                TagValue = "烘焙",
                CountTaged = 0,
            };
            _tagsRep.Insert(newTag);
        }

        private void DeleteTags()
        {
            var items = _tagsRep.Table.ToList();
            foreach (var item in items)
            {
                _tagsRep.Delete(item);
            }
        }

        private void DeleteStatusPointDetail()
        {
            var items = _statusPointDetailRep.Table.ToList();
            foreach (var item in items)
            {
                _statusPointDetailRep.Delete(item);
            }

        }

        private void DeleteCustomerLogs()
        {

            var clList= _customerLogoRep.Table.ToList();
            foreach (var clogo in clList)
            {

                _customerLogoRep.Delete(clogo);
            }

        }

        private void InstallMessages()
        {
            var msg = new Message()
                {
                    Languageid = 0,
                    ResourceName = "CustomerRegistrationService_ValidateCustomer_LoginFailed",
                    ResourceValue = "login failed"
                };
            _messageRep.Insert(EntityNames.Messages,msg);
            msg = new Message()
                {
                    Languageid = 0,
                    ResourceName = "Login.NeedEmailAddress",
                    ResourceValue = "Please supply your Email address."
                };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Login.NeedPassword",
                ResourceValue = "Please supply your Password."
            };
            _messageRep.Insert(EntityNames.Messages,msg); 
            
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Login.Email",
                ResourceValue = "Email"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Login.Password",
                ResourceValue = "Password"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Login.Login",
                ResourceValue = "Sign in"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Login.Title",
                ResourceValue = "Please sign in"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Register.Title",
                ResourceValue = "Please regist"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Register.UserName",
                ResourceValue = "UserName"
            };
            _messageRep.Insert(EntityNames.Messages,msg);



            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Register.Email",
                ResourceValue = "Email"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Register.Password",
                ResourceValue = "Password"
            };
            _messageRep.Insert(EntityNames.Messages,msg);



            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Register.NeedUserName",
                ResourceValue = "Please supply your user name."
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Register.NeedPassword",
                ResourceValue = "Please supply your password."
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Register.NeedEmailAddress",
                ResourceValue = "Please supply your Email address."
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Register.Register",
                ResourceValue = "Register"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = Messages.CustomerRegistrationService_RegisterSuccess,
                ResourceValue = "regist success"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = Messages.CustomerRegistrationService_RegisterFailed,
                ResourceValue = "regist failed"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Cutomer.Logo.Title",
                ResourceValue = "Please Upload Logo"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Cutomer.Logo.Save",
                ResourceValue = "Save Logo"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Cutomer.Logo.SaveSuccess",
                ResourceValue = "Save Successfully"
            };

            //Customer.Logo.CurrentLogo.Title

            _messageRep.Insert(EntityNames.Messages,msg);



            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Customer.Logo.CurrentLogo.Title",
                ResourceValue = "Current Logo"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Customer.Logo.Upload.Title",
                ResourceValue = "Upload New Logo"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "CustomerLogo_Update_Successfully",
                ResourceValue = "Logo Updated Successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Customer.Info.Intro.Title",
                ResourceValue = "Self Introduction"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Customer.Info.NickName.Title",
                ResourceValue = "Nickname"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Cutomer.Info.Save",
                ResourceValue = "Save"
            };
            _messageRep.Insert(EntityNames.Messages,msg);



            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "CustomerInfo_Update_Successfully",
                ResourceValue = "Customer Info Updated Successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Customer.Info.Title",
                ResourceValue = "Please Update Your Info"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.NeedProductName",
                ResourceValue = "Please supply ProductName."
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.Create.Button.Title",
                ResourceValue = "Save"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //Admin.Product.List.ProductName.Title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.List.ProductName.Title",
                ResourceValue = "ProductName"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.List.ProductPictureUrl.Title",
                ResourceValue = "PictureUrl"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.List.IsPublished.Title",
                ResourceValue = "IsPublished"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //Admin.Product.List.Edit.Title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.List.Edit.Title",
                ResourceValue = "Edit"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.NeedShortDescription",
                ResourceValue = "Please supply Short Description."
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.NeedFullDescription",
                ResourceValue = "Please supply Full Description."
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.Product.Create.Title


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.Create.Title",
                ResourceValue = "Create Product"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.Edit.ProductInfo.Tab",
                ResourceValue = "Product Info"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.Edit.ProductPicture.Tab",
                ResourceValue = "Product Picture"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.Edit.ProductSpecificationAttribute.Tab",
                ResourceValue = "ProductSpecificationAttribute"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.Edit.Save.Button",
                ResourceValue = "Save"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ProductUpdateInfoSuccess",
                ResourceValue = "Product Info Update successfully"
            };

            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.Product.Edit.Title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.Edit.Title",
                ResourceValue = "Edit Product"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.Product.List.CreateProduct
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.List.CreateProduct",
                ResourceValue = "Create New Product"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.List.Name",
                ResourceValue = "Name"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //Admin.ProductVariant.List.Sku

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.List.Sku",
                ResourceValue = "Sku"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.NeedName",
                ResourceValue = "Please supply name."
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.NeedDigit
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.PriceFormatError",
                ResourceValue = "Price format wrong"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.Edit.ProductVariant.Tab",
                ResourceValue = "Product Variant"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.NeedPicture

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.NeedPicture",
                ResourceValue = "Plesase upload picture"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.StockQuantityFormatError",
                ResourceValue = "stock quantity format error"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.DisplayOrderFormatError",
                ResourceValue = "display order format error"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ProductVariantCreateInfoSuccess",
                ResourceValue = "save product variant successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.Create.Button.Title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.Create.Button.Title",
                ResourceValue = "save"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Productvariant.Create.Title",
                ResourceValue = "create product variant"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.Edit.Title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.Edit.Title",
                ResourceValue = "edit product variant"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.Edit.Tab.Title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.Edit.Tab.Title",
                ResourceValue = "product variant"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariantAttribute.Edit.Tab.Title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariantAttribute.Edit.Tab.Title",
                ResourceValue = "product variant attribute"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //ProductVariantUpdateSuccess
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ProductVariantUpdateSuccess",
                ResourceValue = "product variant updated successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.Save.Back

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.Save.Back",
                ResourceValue = "back"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariantAttribute.Save.Back",
                ResourceValue = "back"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //"

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantattribute.attribute",
                ResourceValue = "attribute"
            };
            _messageRep.Insert(EntityNames.Messages,msg);
            //admin.productvariantattribute.attributecontroltype

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantattribute.attributecontroltype",
                ResourceValue = "attribute control type"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //admin.productvariantattribute.values
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantattribute.values",
                ResourceValue = "values"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.productvarinatattribute.create.title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvarinatattribute.create.title",
                ResourceValue = "create product variant attribute"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariantAttribute.Create.Button.Title",
                ResourceValue = "save"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.productvariantattribute.delete.button.title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantattribute.delete.button.title",
                ResourceValue = "delete"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ProductVariantAttributeValueDeleteSuccess",
                ResourceValue = "product varinat attribute value deleted successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.productvariantattribute.delete.confirm

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantattribute.delete.confirm",
                ResourceValue = "confirm to delete?"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //Admin.ProductVariant.List.Price

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.List.Price",
                ResourceValue = "Price"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.List.DisplayOrder
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.List.DisplayOrder",
                ResourceValue = "DisplayOrder"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.List.Published   
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.List.Published",
                ResourceValue = "Is Published"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.List.Edit.Button.Title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.List.Edit.Button.Title",
                ResourceValue = "Edit"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.List.Create.Button.Title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.List.Create.Button.Title",
                ResourceValue = "Create ProductVariant"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.productvariantattribute.values.edit.title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantattribute.values.edit.title",
                ResourceValue = "Values Edit"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.productvariantattribute.delete.title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantattribute.delete.title",
                ResourceValue = "delete"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //Admin.ProductVariant.List.Delete.Button.Title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.List.Delete.Button.Title",
                ResourceValue = "delete"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //ProductVariantDeleteSuccess

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ProductVariantDeleteSuccess",
                ResourceValue = "ProductVariant delete successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.productvariant.delete.confirm

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariant.delete.confirm",
                ResourceValue = "confirm to delete product variant?"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.product.delete.title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.product.delete.title",
                ResourceValue = "delete"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.product.delete.confirm

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.product.delete.confirm",
                ResourceValue = "confirm to delete product?"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //ProductDeleteSuccess

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ProductDeleteSuccess",
                ResourceValue = "product deleted successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.Product.Save.Back

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.Product.Save.Back",
                ResourceValue = "back"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.productvariantvalues.name.title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantvalues.name.title",
                ResourceValue = "name"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariantAttributeValue.NeedValue

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariantAttributeValue.NeedValue",
                ResourceValue = "please supply value"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariantAttributeValue.NeedDisplayOrder",
                ResourceValue = "please supply display order"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //Admin.ProductVariantAttributeValue.DisplayOrderFormatError

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariantAttributeValue.DisplayOrderFormatError",
                ResourceValue = "display order format error"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //Admin.ProductVariant.NeedDisplayOrder


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.NeedDisplayOrder",
                ResourceValue = "please supply display order"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.NeedStock

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.NeedStockQuantity",
                ResourceValue = "please supply stock quantity"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //Admin.ProductVariant.NeedPrice

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.NeedPrice",
                ResourceValue = "please supply price"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariantAttributeValues.Save.Back
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariantAttributeValues.Save.Back",
                ResourceValue = "back"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //admin.productvariantvalues.displayorder.title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantvalues.displayorder.title",
                ResourceValue = "display order"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.productvariantattributevalue.delete.title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantattributevalue.delete.title",
                ResourceValue = "delete"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ProductVariantAttributeDeleteSuccess",
                ResourceValue = "product variant attribute delete successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //admin.productvariantattributevalue.delete.confirm
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productvariantattributevalue.delete.confirm",
                ResourceValue = "confirm to delete product variant attribute value?"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductPicture.DisplayOrderFormatError",
                ResourceValue = "display order format error"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductPicture.NeedDisplayOrder
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductPicture.NeedDisplayOrder",
                ResourceValue = "please supply display order"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductPicture.NeedPicture",
                ResourceValue = "please upload picture "
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //"admin.productpicture.displayorder.title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productpicture.displayorder.title",
                ResourceValue = "display order "
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //admin.productpicture.delete.confirm

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "admin.productpicture.delete.confirm",
                ResourceValue = "confirm to delete product picture?"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //ProductPictureDeletedSuccess

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ProductPictureDeletedSuccess",
                ResourceValue = "product picture deleted successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //Admin.ProductVariant.List.StockQuantity

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "Admin.ProductVariant.List.StockQuantity",
                ResourceValue = "stock quantity"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //status.tab.title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "status.tab.title",
                ResourceValue = "post status"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //prod.tab.title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "prod.tab.title",
                ResourceValue = "post product"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //product.post.placeholder.title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "product.post.placeholder.title",
                ResourceValue = "product description"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //ProductStatusUploader.Button.Title 
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ProductStatusUploader.Button.Title",
                ResourceValue = "upload product picture"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //productstatus.productstock.title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "productstatus.productstock.title",
                ResourceValue = "product stock"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //productstatus.productprice.title

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "productstatus.productprice.title",
                ResourceValue = "product price"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            //status.product.buy.title
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "status.product.buy.title",
                ResourceValue = "buy"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            //CommentsAddSuccessfully
            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "CommentsAddSuccessfully",
                ResourceValue = "Comments Added Successfully"
            };
            _messageRep.Insert(EntityNames.Messages,msg);

            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "RegistFailed",
                ResourceValue = "regist failed"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "AvailableTags",
                ResourceValue = "AvailableTags"
            };
            _messageRep.Insert(EntityNames.Messages,msg);


            msg = new Message()
            {
                Languageid = 0,
                ResourceName = "ChoosedTags",
                ResourceValue = "ChoosedTags"
            };
            _messageRep.Insert(EntityNames.Messages,msg);
        }

        private void DeleteMessages()
        {
            var pList = _messageRep.Table(EntityNames.Messages).ToList();
            foreach (var p in pList)
            {
                _messageRep.Delete(p);
            }
        }

        private void DeleteFriendShip()
        {
            var pList = _friendShipRep.Table.ToList();
            foreach (var p in pList)
            {
                _friendShipRep.Delete(p);
            }
        }

        private void DeleteStatuses()
        {
            var pList = _statusRep.Table.ToList();
            foreach (var p in pList)
            {
                _statusRep.Delete(p);
            }
        }

        private void DeleteStatusPictures()
        {
            var pList = _statusPicRep.Table.ToList();
            foreach (var p in pList)
            {
                _statusPicRep.Delete(p);
            }
        }

        private void InstallPermissionRecordRoleMapping()
        {

            
            var manageProduct = new PermissionRecord()
                {
                    SystemName = "ManageProduct"

                };


            var manageOrders = new PermissionRecord()
            {
                SystemName = "ManageOrders"

            };

            var accessAdmin = new PermissionRecord()
            {
                SystemName = "AccessAdmin"

            };

            var manageCustomer = new PermissionRecord()
            {
                SystemName = "ManageCustomers"

            };

            
            var manageShipping = new PermissionRecord()
            {
                SystemName = "ManageShipping"

            };

            
            var manageShop = new PermissionRecord()
            {
                SystemName = "ManageShop"

            };



            var administrator = new CustomerRole()
            {
                Active = true,
                SystemName = "Administrators",
                PermissionRecords = new Collection<PermissionRecord>()
                    {
                        manageProduct,
                        manageOrders,
                        accessAdmin,
                        manageCustomer,
                        manageShipping,
                        manageShop
                    }
            };
            _customerRoleRepository.Insert(administrator);

            var shopowner = new CustomerRole()
            {
                Active = true,
                SystemName = "ShopOwner",

                PermissionRecords = new Collection<PermissionRecord>()
                    {
                        manageProduct,
                        manageOrders,
                        accessAdmin,
                        manageShipping,
                    }
            };
            _customerRoleRepository.Insert(shopowner);


            var role = new CustomerRole()
            {
                Active = true,
                SystemName = "Guests"
            };
            _customerRoleRepository.Insert(role);

            role = new CustomerRole()
            {
                Active = true,
                SystemName = "Registered"
            };
            _customerRoleRepository.Insert(role);

        }

   

        private void DeleteCustomerRole()
        {
            var pList = _customerRoleRepository.Table.ToList();
            foreach (var p in pList)
            {
                _customerRoleRepository.Delete(p);
                foreach (var r in p.PermissionRecords)
                {
                    
                    _permissionRecordRep.Delete(r);
                }
            }
        }

        private int InstallAdministrator()
        {

            var customer = new Customer()
            {
                Active = true,
                Username = "admin",
                Password = _encryptionService.CreatePasswordHash("123456", "aabbcc", "SHA1"),
                Email = "dd@dd.com",
                UserGuid = Guid.NewGuid(),
                Deleted = false,
                CreatedOn = DateTime.Now
            };
            var defaultAddress = new Address()
            {
                FirstName = "Mike",
                LastName = "Yi",
                PhoneNumber = "12345678",
                MobileNumber = "1232323",
                Email = "cc@cc.com",
                Province = "shang hai",
                Address1 = "21 West 52nd Street",
                Address2 = "",
                City = "New York",
                ZipPostalCode = "10021",
                CreatedOnUtc = DateTime.UtcNow,
            };

            _addressRep.Insert(defaultAddress);

            var adminRole= _customerRoleRepository.Table.Where(c => c.SystemName == "Administrators").FirstOrDefault();
            var registedRole = _customerRoleRepository.Table.Where(c => c.SystemName == "Registered").FirstOrDefault();

            customer.CustomerRoles.Add(adminRole);
            customer.CustomerRoles.Add(registedRole);
            customer.ShippingAddress = defaultAddress;

            customer.Addresses.Add(defaultAddress);
            _customerRepository.Insert(customer);
            return customer.Id;
        }

        private int InstallShopOwner()
        {
            var customer = new Customer()
                {
                    Active = true,
                    Username = "shopowner",
                    Password = _encryptionService.CreatePasswordHash("123456", "aabbcc", "SHA1"),
                    Email = "cc@cc.com",
                    UserGuid = Guid.NewGuid(),
                    Deleted = false,
                    CreatedOn = DateTime.Now
                };
            var defaultAddress = new Address()
            {
                FirstName = "John",
                LastName = "Smith",
                PhoneNumber = "12345678",
                MobileNumber = "1232323",
                Email = "admin@yourStore.com",
               Province = "shang hai",
                Address1 = "21 West 52nd Street",
                Address2 = "",
                City = "New York",
                ZipPostalCode = "10021",
                CreatedOnUtc = DateTime.UtcNow,
            };

            _addressRep.Insert(defaultAddress);

            var shopOwerRole = _customerRoleRepository.Table.Where(c => c.SystemName == "ShopOwner").FirstOrDefault();
            var registedRole = _customerRoleRepository.Table.Where(c => c.SystemName == "Registered").FirstOrDefault();

            customer.CustomerRoles.Add(shopOwerRole);
            customer.CustomerRoles.Add(registedRole);
            customer.ShippingAddress = defaultAddress;

            customer.Addresses.Add(defaultAddress);
            _customerRepository.Insert(customer);
            return customer.Id;
        }

        private void InstallCategory()
        {
            var cat = new Category()
                {
                    CreatedOnUtc = DateTime.Now,
                    UpdatedOnUtc = DateTime.Now,
                    Deleted = false,
                    Description = "shirts",
                    DisplayOrder = 1,
                    Name = "shirts",
                    ParentCategoryId = 0,
                };
            _catRep.Insert(cat);


            cat = new Category()
            {
                CreatedOnUtc = DateTime.Now,
                UpdatedOnUtc = DateTime.Now,
                Deleted = false,
                Description = "Jeans",
                DisplayOrder = 1,
                Name = "Jeans",
                ParentCategoryId = 0,
            };
            _catRep.Insert(cat);
        }

        private void InstallBrand()
        {
            var brand = new Brand()
                {
                    Name = "AF",
                    CreatedOnUtc = DateTime.Now,
                    UpdatedOnUtc = DateTime.Now,
                    Published = true,
                    DisplayOrder = 1,
                    Deleted = false,
                    Description = "AF",
                };
            _brandRep.Insert(brand);
        }

        private void InstallAlipayPaymethodSetting()
        {
            var alipaySetting = new AlipayPaymethodSetting()
                {
                    AlipayKey = "key",
                    AlipayPartner = "partner",
                    AlipaySellerEmail = "email@yicommer.com"
                };

            _alipaysettingrep.Insert(alipaySetting);
        }

        private void DeleteAlipayPaymethodSetting()
        {
            var pList = _alipaysettingrep.Table.ToList();
            foreach (var p in pList)
            {
                _alipaysettingrep.Delete(p);
            }
        }

        private void DeleteCategory()
        {
            var pList = _catRep.Table.ToList();
            foreach (var p in pList)
            {
                _catRep.Delete(p);
            }
        }

        private void DeleteBrand()
        {
            var pList = _brandRep.Table.ToList();
            foreach (var p in pList)
            {
                _brandRep.Delete(p);
            }
        }

        private void DeleteAddress()
        {
            var pList = _addressRep.Table.ToList();
            foreach (var p in pList)
            {
                _addressRep.Delete(p);
            }
        }

        private void DeleteCustomer()
        {
            var pList = _customerRepository.Table.ToList();
            foreach (var p in pList)
            {
                _customerRepository.Delete(p);
            }
        }

        private void DeleteCustomerAddress()
        {
        }

        private void DeleteCustomerRoleMapping()
        {
        }

        private void DeletePermissionRecord()
        { var pList = _permissionRecordRep.Table.ToList();
            foreach (var r in pList)
            {

                _permissionRecordRep.Delete(r);
            }
        }

        private void DeletePermissionRecordRoleMapping()
        {
           
        }

        private void DeletePictures()
        {
            var pList = _picturerep.Table.ToList();
            foreach (var p in pList)
            {_picturerep.Delete(p);
            }
        }

        private void DeleteOrder()
        {
        }

        private void DeleteProduct()
        {
            var pList= _productRepository.Table.ToList();
            foreach (var p in pList)
            {
                _productRepository.Delete(p);
            }
        }

        private void DeleteOrderProductVariant()
        {
        }

        private void DeleteProductBrandMapping()
        {
        }

        private void DeleteProductCategoryMapping()
        {
        }

        private void DeleteProductPicutreMapping()
        {
            var pList = _productpicturerep.Table.ToList();
            foreach (var p in pList)
            {
                _productpicturerep.Delete(p);
            }
        }

        private void DeleteProductVariant()
        {

            var pList = _productVariantRepository.Table.ToList();
            foreach (var p in pList)
            {
                _productVariantRepository.Delete(p);
            }

        }

        private void DeleteProductVariantAttributeValue()
        {
        }

        private void DeleteProductAttribute()
        {
            var ss = _productAttributeRepository.Table.ToList();
            foreach (var s in ss)
            {
                _productAttributeRepository.Delete(s);
            }
        }

        private void DeleteProductVariantProductAttributeMapping()
        {
            
        }

        private void DeleteShipment()
        {
            var ss = _shipmentRecordRep.Table.ToList();
            foreach (var s in ss)
            {
                _shipmentRecordRep.Delete(s);
            }
        }

        private void DeleteSpecificationAttribute()
        {
            var ss = _speficationAttributreRepostiory.Table.ToList();
            foreach (var s in ss)
            {
                _speficationAttributreRepostiory.Delete(s);
            }
        }

        private void DeleteProductSpecificationAttributeMapping()
        {
          
        }

        private void DeleteSpecificationAttributeOption()
        {
            var ss = _speficationAttributreOptionRepostiory.Table.ToList();
            foreach (var s in ss)
            {
                _speficationAttributreOptionRepostiory.Delete(s);
            }
        }

        private void DeleteShoppingCartItem()
        {
            var ss = _shoppingCartItemRep.Table.ToList();
            foreach (var s in ss)
            {
                _shoppingCartItemRep.Delete(s);
            }
            
        }

        private void DeleteSystemSetting()
        {
            var ss = _systemSettingRep.Table.ToList();
            foreach (var s in ss)
            {
                _systemSettingRep.Delete(s);
            }
        }

        private void InstallSystemSetting()
        {
            var ss = new SystemSetting()
                {
                    StoreLocation = "www.yicommerce.com"
                };
            _systemSettingRep.Insert(ss);
        }
        private void DeleteTradingId()
        {
            var idList= _tradingIdRep.Table.ToList();
            foreach (var t in idList)
            {
                _tradingIdRep.Delete(t);
            }
        }

        private void DeleteTradings()
        {
            var tradingList = _tradingRep.Table.ToList();
            foreach (var t in tradingList)
            {
                _tradingRep.Delete(t);
            }

        }

        private void DeleteOrders()
        {

            var orderList = _orderRep.Table.ToList();
            foreach (var order in orderList)
            {
              
                _orderRep.Delete(order);
            }

        }

        private void InstallCustomerRole()
        {

           
        }

        private void InstallSpecificationAttributeOptions()
        {
            
        }
        private void InstallSpecificationAttributes()
        {

            var p = new SpecificationAttribute()
                {
                    DisplayOrder = 1,
                    Name = "Screen Size"
                };
            _speficationAttributreRepostiory.Insert(p);

            var o = new SpecificationAttributeOption()
                {
                    SpecificationAttributeId = p.Id,
                    Name = "10.0"
                };

            _speficationAttributreOptionRepostiory.Insert(o);

            o = new SpecificationAttributeOption()
            {
                SpecificationAttributeId = p.Id,
                Name = "20.0"
            };

            _speficationAttributreOptionRepostiory.Insert(o);

            p = new SpecificationAttribute()
                {
                    DisplayOrder = 2,
                    Name = "CPU Type"
                };
            _speficationAttributreRepostiory.Insert(p);


            o = new SpecificationAttributeOption()
            {
                SpecificationAttributeId = p.Id,
                Name = "Intel"
            };

            _speficationAttributreOptionRepostiory.Insert(o);
            o = new SpecificationAttributeOption()
            {
                SpecificationAttributeId = p.Id,
                Name = "AMD"
            };

            _speficationAttributreOptionRepostiory.Insert(o);
        }

        private void InstallProductAttribute()
        {
            var pa = new ProductAttribute()
                {
                    Description = "Color",
                    Name = "Color"
                };

            _productAttributeRepository.Insert(pa);

            pa = new ProductAttribute()
            {
                Description = "Size",
                Name = "Size"
            };

            _productAttributeRepository.Insert(pa);
        }

        private int InstallCustomer()
        {
            var customer = new Customer()
            {
                Active = true,
                Username = "zhuzhu",
                Password = _encryptionService.CreatePasswordHash("123456", "aabbcc", "SHA1"),
                Email = "ee@ee.com",
                UserGuid = Guid.NewGuid(),
                Deleted = false,
                CreatedOn = DateTime.Now
            };
            var defaultAddress = new Address()
            {
                FirstName = "Mike",
                LastName = "Yi",
                PhoneNumber = "12345678",
                MobileNumber = "1232323",
                Email = "ee@ee.com",
                Province = "shang hai",
                Address1 = "21 West 52nd Street",
                Address2 = "",
                City = "New York",
                ZipPostalCode = "10021",
                CreatedOnUtc = DateTime.UtcNow,
            };

            _addressRep.Insert(defaultAddress);

            var registedRole = _customerRoleRepository.Table.Where(c => c.SystemName == "Registered").FirstOrDefault();

            customer.CustomerRoles.Add(registedRole);
            customer.ShippingAddress = defaultAddress;

            customer.Addresses.Add(defaultAddress);
            _customerRepository.Insert(customer);
            return customer.Id;
        }

        private void InstallShop(int shopOwnerId, int adminId, int customerId)
        {

            var shop = new Shop()
                {
                    ShopName = "hello world",
                    CustomerId = shopOwnerId
                };
            _shopRepository.Insert(shop);

            var customer = _customerRepository.GetById(shopOwnerId);
            customer.ShopId = shop.Id;
            _customerRepository.Update(customer);


            shop = new Shop()
            {
                ShopName = "hello world",
                CustomerId = adminId
            };
            _shopRepository.Insert(shop);

            customer = _customerRepository.GetById(adminId);
            customer.ShopId = shop.Id;
            _customerRepository.Update(customer);


            shop = new Shop()
            {
                ShopName = "hello world",
                CustomerId = customerId
            };
            _shopRepository.Insert(shop);

            customer = _customerRepository.GetById(customerId);
            customer.ShopId = shop.Id;
            _customerRepository.Update(customer);
        }

        private void InstallShippingAddress()
        {
            
        }




      
    }
}
